package idempotence

import (
	"github.com/google/uuid"
)

type Generator interface {
	Generate() (string, error)
}

type GeneratorFunc func() (string, error)

func (f GeneratorFunc) Generate() (string, error) {
	return f()
}

func generateUUIDString() (string, error) {
	u, err := uuid.NewRandom()
	if err != nil {
		return "", err
	}
	return u.String(), nil
}

var UUIDGenerator = GeneratorFunc(generateUUIDString)
